import { Vector3, Vector3Tuple } from "three";
import * as THREE from 'three'
import { IEditorHistoryOptions } from "../EditorHistory";
import { EditorModels } from "../EditorModels";
export enum EnumEditorCommandType {
    /** 设置位置 */
    SetPositionCommand = 'SetPositionCommand',
    /** 设置缩放 */
    SetScaleCommand = 'SetScaleCommand',
    /** 设置旋转 */
    SetRotateCommand = 'SetRotateCommand',
    /** 添加对象 */
    AddObjectCommand = 'AddObjectCommand',
    /** 删除对象 */
    RemoveObjectCommand = 'RemoveObjectCommand',
    /** 设置材质 */
    SetMaterialCommand = 'SetMaterialCommand'
}
export enum EnumEditorCommandName {
    SetPosition = 'SetPosition',
    SetScale = 'SetScale',
    SetRotate = 'SetRotate',
    AddObject = 'AddObject',
    RemoveObject = 'RemoveObject',
    SetMateria = 'SetMateria'
}

export interface IEditorCommandOutput {
    type: string;
    id: number;
    name: string;
    uuid?: string;
    oldPosition?: Vector3Tuple;
    newPosition?: Vector3Tuple;
    oldScale?: Vector3Tuple;
    newScale?: Vector3Tuple;
    oldRotation?: [number, number, number];
    newRotation?: [number, number, number];
}
export default abstract class EditorCommand {
    editor: EditorModels;
    id = - 1;
    inMemory = false;
    updatable = false;
    type = '';
    name = '';
    constructor(options: IEditorHistoryOptions) {
        this.editor = options.editor
    }
    abstract execute(): void
    abstract undo(): void
    abstract update(params: this): void
    toJSON() {
        let output: IEditorCommandOutput = {
            type: this.type,
            id: this.id,
            name: this.name,
        };
        return output;
    }

    fromJSON(json: IEditorCommandOutput) {
        this.inMemory = true;
        this.type = json.type;
        this.id = json.id;
        this.name = json.name;
    }

}
